#include<stdio.h>
int main()
{
    int num,i=0;
    int a,b,c,t=0,num1,num2;
    scanf("%d",&num);
    do{
        a=num/100;
        b=num/10%10;
        c=num%10;
        if(a>b)
        {
            t=a;
            a=b;
            b=t;
        }
       if(a>c)
        {
            t=a;
            a=c;
            c=t;
        }
        if(b>c)
        {
            t=b;
            b=c;
            c=t;
        }
        num1=c*100+b*10+a;
            num2=a*100+b*10+c;
            num=num1-num2;
       i++;
       printf("%d: %d - %d = %d\n",i,num1,num2,num1-num2);
        }while(num!=495&&num!=0);
        
	}
